<template>
  <div class="echarts">
    <div id="main"></div>
  </div>
</template>
<script>
import echarts from "echarts";
export default {
  data() {
    return {
      list: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
      data: [100, 20, 36, 10, 10, 20]
    };
  },
  mounted() {
    // 获取dom, 在dom中渲染canvas绘图
    this.getEcharts();
  },
  methods: {
    getEcharts() {
      var myChart = echarts.init(document.getElementById("main"));
      // 绘制图表
      myChart.setOption({
        title: {
          text: "ECharts 入门示例"
        },
        tooltip: {},
        xAxis: {
          data: this.list
        },
        yAxis: {},
        series: [
          {
            name: "销量",
            type: "line",
            data: this.data
          }
        ]
      });
    }
  }
};
</script>

<style lang="scss">
#main {
  width: 800px;
  height: 600px;
}
</style>